package cn.edu.fzu.delivery.domain.enums;

/**
 * 快递状态
 *
 * @author fangxin
 * @date 2022/11/3
 */
public enum CourierStatusEnum implements SpringConvertibleEnum {

    ERROR(-3, "取件失败"),
    CANCEL(-2, "已取消"),
    LOSE(-1, "丢失"),
    UNCOLLECTED(0, "待揽件"),
    COLLECTED(1, "已揽件"),
    SEND(2, "已发货"), //感觉没必要
    TRANSIT(3, "运输中"),
    DELIVERY(4, "派送中"),
    WAIT(5, "待取件"), //感觉没必要
    ARRIVED(6, "已签收");

    private final int    value;

    private final String desc;

    private CourierStatusEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    public int getValue() {
        return value;
    }


    public String getDesc() {
        return desc;
    }


    public static CourierStatusEnum parse(int value) {
        switch (value) {
            case -3:
                return ERROR;
            case -2:
                return CANCEL;
            case -1:
                return LOSE;
            case 0:
                return UNCOLLECTED;
            case 1:
                return COLLECTED;
            case 2:
                return SEND;
            case 3:
                return TRANSIT;
            case 4:
                return DELIVERY;
            case 5:
                return WAIT;
            case 6:
                return ARRIVED;
            default:
                return null;
        }
    }


    @Override
    public String toString() {
        return String.valueOf(getValue());
    }
}
